package com.top75;

import com.bean.ListNode;

/**
 * @Author: huangzhigao
 * @Date: 2023/5/22 20:04
 */
public class Code2095 {
    public ListNode deleteMiddle(ListNode head) {
        if (head.next == null) return null; // 边界情况。
        ListNode fast = head;
        ListNode slow = new ListNode();
        slow.next = head;
        while (fast.next != null) { // 快指针不是尾节点时。
            if (fast.next.next != null) {
                fast = fast.next.next;
            } else {
                fast = fast.next;
            }
            slow = slow.next;
        }
        slow.next = slow.next.next;
        return head;
    }
}
